<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
        <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>访客管理系统</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/3rd/X-admin/css/font.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/3rd/X-admin/css/xadmin.css">
        <script src="${pageContext.request.contextPath}/3rd/X-admin/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/3rd/X-admin/js/xadmin.js"></script>
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">
                                用户名称：
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="name" id="name" >
                                </div>
                                &nbsp;&nbsp;
                                手机号：
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="phone" id="phone" >
                                </div>
                                备注：
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="remark" id="remark" >
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加用户','/userManager/user-add',430,470)"><i class="layui-icon"></i>添加用户</button>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                              <thead>
                                <tr>
                                  <th>用户编号</th>
                                  <th>用户登录帐号</th>
                                  <th>用户名称</th>
                                  <th>用户年龄</th>
                                  <th>手机号</th>
                                  <th>密码</th>
                                  <th>头像</th>
                                  <th>创建时间</th>
                                  <th>备注</th>
                                  <th>操作</th>
                              </thead>
                              <tbody>
                              <c:forEach items="${page.list}" var="list">
                                <tr>
                                  <td>${list.id}</td>
                                  <td>${list.account}</td>
                                  <td>${list.name}</td>
                                  <td>${list.age}</td>
                                  <td>${list.phone}</td>
                                  <td>${list.password}</td>
                                    <td><img src="${list.headPic}" style="width: 60px;"></td>
                                   <td>${list.createTime}</td>
                                   <td>${list.remark}</td>
                                   <td class="td-manage">
                                    <a title="修改"  onclick="update(this,${list.id})" href="javascript:;">
                                      <i class="layui-icon">&#xe642;</i>
                                    </a>
                                    <a title="删除" onclick="delUser(this,${list.id})" href="javascript:;">
                                      <i class="layui-icon">&#xe640;</i>
                                    </a>
                                  </td>
                                </tr>
                              </c:forEach>
                              </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page">
                                <div>
                                    <a class="layui-laypage-next ${page.isFirstPage ?'layui-disabled':''}" href="${pageContext.request.contextPath}/userManager/userList?pageNum=${page.isFirstPage?page.pageNum:page.prePage}">上一页</a>
                                    <a class="num" href="">${page.pageNum}/${page.pages}</a>
                                    <a class="next ${page.isLastPage?'layui-disabled':''}" href="${pageContext.request.contextPath}/userManager/userList?pageNum=${page.isLastPage?page.pageNum:page.nextPage}" >下一页</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script>
      layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
      });
      function update(obj,id) {
          xadmin.open('修改用户信息','${pageContext.request.contextPath}/userManager/user-edit?id='+id,430,470);
      }

      /*用户-删除*/
      function delUser(obj, id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $.post("${pageContext.request.contextPath}/userManager/delUser/"+id,  function (data) {
                  var result=eval(data);
                  if (result.status==200) {
                      $(obj).parents("tr").remove();
                      layer.alert("删除成功", {icon: 6 });
                  } else {
                      layer.alert("删除失败", {
                              icon: 6
                          },
                          function() {
                              var index = parent.layer.getFrameIndex(window.name);
                              parent.layer.close(index);
                          });
                  }
              });
          });
      }
    </script>
</html>